package com.yunzheng.studyLeaveSystem.modules.user.adjust.record.servlet; /**
 * Created with IntelliJ IDEA.
 *
 * @Author: YunZheng
 * @Date: 2023/01/31/15:02
 * @Description:
 */

import com.alibaba.fastjson.JSON;
import com.yunzheng.studyLeaveSystem.modules.response.ResponseWrapper;
import com.yunzheng.studyLeaveSystem.modules.user.adjust.adjust.service.AdjustService;
import com.yunzheng.studyLeaveSystem.modules.user.adjust.record.service.RecordService;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

/*
 *将该用户本周调研学的数量传递给前端
 */
@WebServlet(name = "AdjustAccountServlet", value = "/AdjustAccountServlet")
public class AdjustAccountServlet extends HttpServlet {
    private RecordService recordService = new RecordService();
    private AdjustService adjustService = new AdjustService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        session.setAttribute("id",7);
        int id = (int) session.getAttribute("id");
        int i = 0;
        try {
            i = recordService.quaryAdjustNum(id);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        ResponseWrapper responseWrapper = ResponseWrapper.Success(i);
        String s = JSON.toJSONString(responseWrapper);
        response.getWriter().println(s);
        System.out.println(s);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
